package com.mck.controller;

import com.mck.entity.Result;
import com.mck.entity.BackgroundColor;
import com.mck.service.BackgroundService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/admin/backgroundColor")
@Slf4j
public class BackgroundColorController {

    @Autowired
    private BackgroundService backgroundService;

    /**
     * 获取背景颜色
     */
    @GetMapping
    public Result getBackgroundColor() {
        log.info("获取背景颜色");

        List<BackgroundColor> backgroundColorList = backgroundService.getBackgroundColor();
        return Result.success(backgroundColorList);
    }

    /**
     * 更新背景颜色
     */
    @PutMapping
    public Result updateBackgroundColor(@RequestBody BackgroundColor backgroundColor) {
        log.info("更新背景颜色");

        backgroundService.updateBackgroundColor(backgroundColor);
        return Result.success();
    }
}
